Ext.define('Risk.controller.rv.RvController', {
    extend : 'Ext.app.Controller',
    stores : ['rv.Pv1Store1','rv.Pv1Store2','rv.Pv1Store3','rv.Pv1Store4','rv.Pz1Store1','rv.Pz1Store2','rv.Pz1Store3','rv.Pz1Store4'],
    models : [

    ],
    views : ['rv.Pv1','rv.Pv2','rv.Pz1','rv.Pz2','rv.Ce1','rv.Ce2','rv.RvResult'],
    init : function() {
        this.control({
                    'pv1fieldSet>radiogroup>radio':{
                        change:function(obj,value){
                            obj.up('pv1fieldSet').down('#combo'+obj.inputValue).setDisabled(!value);
                            var comboValue = obj.up('pv1fieldSet').down('#combo'+obj.inputValue).value;
                        }
                    },
                    'pv1fieldSet>radiogroup>combo':{
                        change:function(obj,value){
                            obj.up('form').down('#pv1').setValue(value);
                        }
                    },
                    'pv2fieldSet>radiogroup>radio':{
                        change:function(obj,value){
                            obj.up('pv2fieldSet').down('#combo'+obj.inputValue).setDisabled(!value);
                            var comboValue = obj.up('pv2fieldSet').down('#combo'+obj.inputValue).value;
                        }
                    },
                    'pv2fieldSet>radiogroup>combo':{
                        change:function(obj,value){
                            obj.up('form').down('#pv2').setValue(value);
                        }
                    },
                    'pz1fieldSet>radiogroup>radio':{
                        change:function(obj,value){
                            obj.up('pz1fieldSet').down('#combo'+obj.inputValue).setDisabled(!value);
                            var comboValue = obj.up('pz1fieldSet').down('#combo'+obj.inputValue).value;
                        }
                    },
                    'pz1fieldSet>radiogroup>combo':{
                        change:function(obj,value){
                            obj.up('form').down('#pz1').setValue(value);
                        }
                    },
                    'pz2fieldSet>radiogroup>radio':{
                        change:function(obj,value){
                            obj.up('pz2fieldSet').down('#combo'+obj.inputValue).setDisabled(!value);
                            var comboValue = obj.up('pz2fieldSet').down('#combo'+obj.inputValue).value;
                        }
                    },
                    'pz2fieldSet>radiogroup>combo':{
                        change:function(obj,value){
                            obj.up('form').down('#pz2').setValue(value);
                        }
                    },
                    'ce1fieldSet>radiogroup>radio':{
                        change:function(obj,value){
                            if (value) {
                                obj.up('form').down('#ce1').setValue(obj.inputValue);
                            }
                        }
                    },
                    'ce2fieldSet>radiogroup>radio':{
                        change:function(obj,value){
                            if (value) {
                                obj.up('form').down('#ce2').setValue(obj.inputValue);
                            }
                        }
                    },
                    'rvpanel':
                    {
                    	 activate: this.getData
                    }
                    
                });
    },
    getData:function(obj)
	{
		var record = obj.up("maintab").ownerCt.ownerCt.items.get(0).getSelectionModel().selected.items[0];
		if(!obj.isLoad){
			obj.isLoad = true;
			Ext.Ajax.request({
			    url:'rv/setRv.do' ,
			    params:{projid:record.data.id,_doc:new Date().getMilliseconds()},
			    success:function(response){
			    //成功操作form 注入数据
			    	
			    	var result = Ext.JSON.decode(response.responseText).success;
			    	if(result){
				    	var o = Ext.JSON.decode(response.responseText).others;
				    	obj.getForm().setValues(o);
				    	
				    	obj.items.get(0).down('radio[checked=true]').next('combo').setValue(o.pvpow2);
				    	obj.items.get(1).down('radio[checked=true]').next('combo').setValue(o.pvcom2);
				    	obj.items.get(2).down('radio[checked=true]').next('combo').setValue(o.pzpow2);
				    	obj.items.get(3).down('radio[checked=true]').next('combo').setValue(o.pzcom2);
			    	}else
			    	{
			    		//obj.getForm().reset();
			    	}
			    },
			    failure:function(response){
			     // 失败操作from 
			    	//obj.getForm().reset();
			    }
			});
		}
		
	}
});